package com.shiwu.client.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * 作者：LCG
 * 创建时间：2019/4/2 18:30
 * 描述：
 */
@Component
public class ClientService {
    @Autowired
    private ClientMapper clientMapper;

    @Autowired
    private ClientApi clientApi;

    @Transactional
    public int updateKucun(Map<String,Object> map){

        //插入订单数据
        int i = clientMapper.insertOneOrder ( map );

        //调用接口锁定库存
        try{
           if(i==1){
               clientApi.updateKucun ( map );
           }
        }catch (Exception e){
            //向定时任务表中插入数据
            clientMapper.insertOneTask ( map );
            e.printStackTrace ();
        }

        return i;
    }

}
